﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace _02.HumanClasses
{
    class Program
    {
        static void Main(string[] args)
        {

            //Adding students
            List<Student> studentArray = new List<Student>(10);
            studentArray.Add(new Student("Pesho", "Draganov", 10));
            studentArray.Add(new Student("Ivan", "Mitkov", 11));
            studentArray.Add(new Student("Dimitar", "Peshev", 5));
            studentArray.Add(new Student("Gosho", "Ivanov", 7));
            studentArray.Add(new Student("Petio", "Peshev", 12));
            studentArray.Add(new Student("Dragan", "Petkanov", 11));
            studentArray.Add(new Student("Kiro", "Peshev", 8));
            studentArray.Add(new Student("Asen", "Apeshev", 8));
            studentArray.Add(new Student("Petkan", "Beshev", 10));
            studentArray.Add(new Student("Pesho", "Zeshev", 10));


            //Sorting students
            var sortedStudentsByGrade =
                                       from student in studentArray
                                       orderby student.Grade ascending
                                       select student;

            //Printing the sorted list of students
            Console.WriteLine("The sorted list of Students:");
            foreach (var item in sortedStudentsByGrade)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine();

            //Making workers
            Worker worker1 = new Worker("Ivan", "Peshev", 123.60, 8);
            Worker worker2 = new Worker("Pesho", "Ivanov", 170.10, 13);
            Worker worker3 = new Worker("Mitko", "Petkov", 145, 8);
            Worker worker4 = new Worker("Strahil", "Ivanov", 201.49, 10);
            Worker worker5 = new Worker("Dimitar", "Kolev", 121.60, 6);
            Worker worker6 = new Worker("Ivan", "Nikolaev", 150.65, 8);
            Worker worker7 = new Worker("Nikolai", "Ivanov", 183.70, 9);
            Worker worker8 = new Worker("Krasi", "Ivanov", 90.60, 8);
            Worker worker9 = new Worker("Joro", "Krasimirov", 303.90, 14);
            Worker worker10 = new Worker("Asencho", "Asenov", 103.60, 5);

            //Adding workers to list of workers
            List<Worker> workers = new List<Worker>{worker1, worker2, worker3,
                worker4, worker5, worker6, worker7, worker8, worker9, worker10};

            //Sorting workers by Money per hour in descending
            var orderedWorkers =
                                from worker in workers
                                orderby worker.MoneyPerHour() descending
                                select worker;

            //Printing the sorted workers
            Console.WriteLine("The sorted workers:");
            foreach (var item in orderedWorkers)
            {
                Console.WriteLine(item);
            }

            //Making a list of humans so we can merge the two lists of students and workers
            List<Human> workersAndStudentsList = new List<Human>();
            for (int index = 0; index < workers.Count; index++)
            {
                workersAndStudentsList.Add((Human)workers[index]);
            }

            Console.WriteLine();

            for (int index = 0; index < studentArray.Count; index++)
            {
                workersAndStudentsList.Add((Human)studentArray[index]);
            }

            //Sorting the humans
            var orderedHumans =
                                from human in workersAndStudentsList
                                orderby human.FirstName ascending, human.LastName ascending
                                select human;

            //Printing humans in the sorted list by first and last name
            Console.WriteLine("The sorted humans");
            foreach (var item in orderedHumans)
            {
                Console.WriteLine(item);   
            }     
        }
    }
}